
{%extends 'df_goods/base.html'%}
{% block head %}
<script>
 $(function() {
     $('.add_goods').click(function () {
         id = $(this).attr('id')
         url = '/cart/add' + id + '_1/';
         $.get(url, function (data) {
             $('#show_count').text(data.count);
         })
     })
 })
</script> 
{% endblock head%}
{% block list %}
<div class="r_wrap fr clearfix">
    <div class="sort_bar">
        <a href="/goods/list{{typeid}}_1_1"
           {%if sort == "1"%}
        class="active"
        {%endif%}
        >默认</a>
        <a href="/goods/list{{typeid}}_1_2"
           {%if sort == "2"%}
        class="active"
        {%endif%}
        >价格</a>
        <a href="/goods/list{{typeid}}_1_3"
           {%if sort == "3"%}
        class="active"
        {%endif%}
        >人气</a>
    </div>
    <ul class="goods_type_list clearfix">
        {%for g in goodList%}
        <li>
            <a href="/goods/{{g.id}}"><img src="/static/{{g.gpic}}"></a>
            <h4><a href="/goods/{{g.id}}">{{g.gtitle}}</a></h4>
            <div class="operate">
                <span class="prize">￥{{g.gprice}}</span>
                <span class="unit">{{g.gunit}}</span>
                {% if request.session.user_name|default:'' != '' %}
					<a href="javascript:;" id="{{ g.id }}" class="add_goods" title="加入购物车"></a>
                    {% comment %} <a href="/cart/add{{g.id}}_1" id="{{ g.id }}" class="add_goods" title="加入购物车"></a> {% endcomment %}
				{% else %}
      				<a href="/user/login/" class="add_goods" title="加入购物车"></a>
				{% endif %}
            </div>
        </li>
        {%endfor%}
    </ul>

    <div class="pagenation">
        {% if goodList.has_previous %}
        <a href="/goods/list{{typeid}}_{{goodList.previous_page_number}}_{{sort}}"><上一页</a>
        {% endif %}

        {%for pindex in pindexlist%}
        <!--如果选择的是当前页，则标记为活动样式-->
        {%if pindex == pageid%}
        <a href="#" class="active">{{pindex}}</a>
        {%else%}
        <a href="/goods/list{{typeid}}_{{pindex}}_{{sort}}">{{pindex}}</a>
        {%endif%}
        {%endfor%}
        {% if goodList.has_next %}
        <a href="/goods/list{{typeid}}_{{goodList.next_page_number}}_{{sort}}">下一页></a>
        {% endif %}
    </div>
</div>
</div>
{%endblock list%}